<?php

namespace App\Http\Controllers\Front;

use App\Common\Controllers\Front\FrontController;
use App\Enums\NoticeWayEnums;
use App\Services\MessageService;
use Illuminate\Http\Request;

class MessageController extends FrontController
{
    /**
     * constructor.
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * @param Request $request
     * @return mixed
     * @throws \App\Common\Tools\CustomException
     * 飞书
     */
    public function feishu(Request $request){
        $data = $request->post();

        $messageService = new MessageService();
        $ret = $messageService->create($data, NoticeWayEnums::FEISHU);

        return $this->ret($ret, $messageService->getModel());
    }

    /**
     * @param Request $request
     * @return mixed
     * @throws \App\Common\Tools\CustomException
     * 阿里短信验证码
     */
    public function alismsCaptcha(Request $request){
        $data = $request->post();

        $messageService = new MessageService();
        $ret = $messageService->create($data, NoticeWayEnums::ALISMS);

        return $this->ret($ret, $messageService->getModel());
    }
}
